package C.e.try_catch;


import java.io.FileOutputStream;
import java.io.IOException;

public class AutoCloseableDemo {
    public static void main(String[] args) {
       /* System.out.println("开始");
        try(
            FileOutputStream fos=new FileOutputStream("fos.dat");
            //只有实现了AutoCloseable接口的类才能在此处定义
            //String str="abc";//编译错误
        ){
            fos.write(1);
        }catch ( IOException e){
            e.printStackTrace();
        }
        System.out.println("结束");*/


        //S t Ff=(dat) f.w(5) c(Ie) e.p S
        System.out.println("start");
        try (
            FileOutputStream fos=new FileOutputStream("i.dat");
         // String str="qdw"  ;
        ){fos.write(5);
        }catch (IOException e){
            e.printStackTrace();
        }
        System.out.println("end");
    }
}
